// SceneDC.cpp: implementation of the CSmartDC class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SmartDC.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSmartDC::CSmartDC(CDC *pDC, CSize cSize)
{
	pSrcDC = pDC;
   dcSize = cSize;

	CreateCompatibleDC(pDC);

	memBitmap.CreateCompatibleBitmap(pDC, cSize.cx, cSize.cy);
	pOldBmp = SelectObject(&memBitmap);
}

void CSmartDC::Clear(COLORREF clr)
{
  FillSolidRect(0,0,dcSize.cx, dcSize.cy, clr);
}

CSmartDC::~CSmartDC()
{
	pSrcDC->BitBlt(0,0, dcSize.cx, dcSize.cy, this,0,0,SRCCOPY);
 
	SelectObject(pOldBmp);
	memBitmap.DeleteObject();
	DeleteDC();
}
